package cn.jy.task.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jy.task.domain.Incomeexpenditure;
import cn.jy.task.mapper.IncomeexpenditureMapper;
import cn.jy.task.service.IStartMonthPlanService;
@Service
public class StartMonthPlanServiceImpl implements IStartMonthPlanService {
	@Autowired
	IncomeexpenditureMapper incomeexpenditureMapper;
    Logger   logger=Logger.getLogger(StartMonthPlanServiceImpl.class);
	@Override
	public void startIncomeexpenditurePlan() {
		 String now = new SimpleDateFormat("yyyy-MM").format(new Date());
		List<Incomeexpenditure> IncomeexpenditureList = incomeexpenditureMapper.selectByCondition("jhyf like '"+now+"%'  and rwzt=0 and rwwczt=0");
		for (Incomeexpenditure incomeexpenditure : IncomeexpenditureList) {
			incomeexpenditure.setRwzt(1);
			incomeexpenditure.setJhqdsj(new Date());
			logger.info( new SimpleDateFormat("yyyy-MM-dd").format(incomeexpenditure.getJhyf())+"---"+incomeexpenditure.getIename());
			logger.info("收支"+incomeexpenditure.getSzlx()+"---"+incomeexpenditure.getJhje());
			incomeexpenditureMapper.updateByPrimaryKey(incomeexpenditure);
		}
	}

}
